package com.t216.dm216.common;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class MD5Util {
    public static String md5(String info){
        MessageDigest md5 = null;
        try {
            md5 = MessageDigest.getInstance("MD5");
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException(e);
        }
        md5.update(info.getBytes());
        byte [] bytes = md5.digest();
        StringBuffer sb = new StringBuffer();
        for (byte aByte : bytes) {
            //byte类型转换为16进制的数字
            sb.append(String.format("%02x", aByte));
        }
        return sb.toString();
    }
}
